<template>
	<view class="flex justify-center items-center pt-16">
		<el-form ref="ruleFormRef" style="width:400px" :model="form" :rules="rules" label-width="auto">
			<el-form-item label="旧密码" prop="oldPassword">
				<el-input v-model="form.oldPassword" placeholder="请输入旧密码" />
			</el-form-item>
			<el-form-item label="新密码" prop="newPassword">
				<el-input v-model="form.newPassword" placeholder="请输入新密码" />
			</el-form-item>
			<el-form-item label="确认密码" prop="confirmPassword">
				<el-input v-model="form.confirmPassword" placeholder="请输入新密码" />
			</el-form-item>
			<el-form-item label=" ">
				<el-button type="primary" @click="submitForm">确认修改</el-button>
				<el-button @click="resetForm">取消</el-button>
			</el-form-item>
		</el-form>
	</view>
</template>

<script>
	import {
		mapState,
		mapActions
	} from 'vuex'
	export default {
		data() {
			return {
				form: {
					oldPassword: '',
					newPassword: '',
					confirmPassword: '',
				},
				rules: {
					oldPassword: [{
						required: true,
						message: '必填项',
						trigger: 'blur'
					}],
					newPassword: [{
						required: true,
						message: '必填项',
						trigger: 'blur'
					}],
					confirmPassword: [{
						required: true,
						message: '必填项',
						trigger: 'blur'
					}],
				}
			}
		},
		computed: {
			...mapState({
				mode: state => state.app.mode
			})
		},
		methods: {
			async submitForm() {
				await this.$refs.ruleFormRef.validate((valid, fields) => {
					if (valid) {
						uni.$http.post('/saasWapAuth/editPwd',this.form).then(res => {
							if (res.code == 200) {
								uni.showToast({
									title: res.msg
								});
							}
						})
					} else {
						console.log('error submit!', fields)
					}
				})
			}
		}
	}
</script>

<style>
</style>